import axios from 'axios'

//获取用户
export const reqGetUsers = (page, limit) => {
  return axios({
    method: 'GET',
    url: `/api/users/${page}/${limit}`,
  })
}

//新增用户
export const reqAddUser = (user) => {
  return axios({
    method: 'POST',
    url: '/api/users',
    data: user,
  })
}

//修改用户
export const reqUpdateUser = (user) => {
  return axios({
    method: 'PUT',
    url: `/api/users/${user.id}`,
    data: {
      username: user.username,
      nickname: user.nickname,
      password: user.password,
    },
  })
}

//删除用户
export const reqDeleteUser = (id) => {
  return axios({
    method: 'DELETE',
    url: `/api/users/${id}`,
  })
}
